/**
 * URL ENCODER
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this page.
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please contact twitter
 * to k.kodama so we can send you a copy immediately.
 *  
 * @category   javascript
 * @package    js here
 * @copyright  Copyright (c) 2012 agniuek
 * @license    New BSD License
 */

var UrlEncoder = {};
objectNameTo = "to_result";
objectNameFrom = "to_convert";
/*
 * encode_uri  Encode URI
 * @param {type} argString
 * @returns {unresolved}
 */
UrlEncoder.encode_uri = function(argString) {

    if ((argString === null) || (argString === "")) {
        return "";
    }
    return encodeURI(argString);
};
UrlEncoder.decode_uri = function(argString) {
    if ((argString === null) || (argString === "")) {
        alert("nothing to convert text");
        return "";
    }
    var decode_uri = decodeURI(argString);
    return decode_uri.replace(/</g, "&lt;");
};
UrlEncoder.showResult = function(argString,objectNameTo) {
    document.getElementById(objectNameTo).innerHTML = "";
    document.getElementById(objectNameTo).innerHTML = argString;
};
UrlEncoder.showEncodeUri = function(argString) {
    var result = encodeURI(argString);
    UrlEncoder.showResult(result,objectNameTo);
};
UrlEncoder.showDecodeUri = function(argString) {
    if ((argString === null) || (argString === "")) {
        alert("nothing to convert text");
        return "";
    }
    var result = UrlEncoder.decode_uri(argString);
    UrlEncoder.showResult(result,objectNameTo);
};
/*
 * reset Reset TextValue
 */
UrlEncoder.reset = function(objectNameTo) {
    document.getElementById(objectNameTo).innerHTML = "";
};
